{include file="public/user_shop_head" /}
{include file="public/href" /}
<link rel="stylesheet" type="text/css" href="__STATIC__/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="__STATIC__/css-wap/style.css">
<style>


    .wrap-cre .yhq1  .dollar {
        font-size: 20px;
        top: 28%;
        left: 8%;
        position: absolute;
        color: white;
    }

    .wrap-cre .yhq1 .price {
        font-size: 34px;
        top: 4%;
        left: 24%;
        position: absolute;
        color: white;
    }

    .wrap-cre .yhq1 .use {
        font-size: 12px;
        bottom: 2%;
        left: -4%;
        transform: scale(0.8);
        display: block;
        width: 80%;
        text-align: center;
        position: absolute;
        color: white;
    }
</style>
<div class="main">
    <ul class="list">
        <li class="cur"><span><a href="shop_index?shop_id={:input('shop_id')}">店铺首页</a></span></li>
        <li ><span><a href="all_goods?shop_id={:input('shop_id')}">全部商品</a></span></li>
        <li><span><a href="sales_promote?shop_id={:input('shop_id')}">促销</a></span></li>
        <li><span><a href="new_list?shop_id={:input('shop_id')}">上新</a></span></li>
    </ul>
    <div class="yhq1" style="margin: 10px 0;">
        {if condition="$result.coupon"}
        {volist name='result.coupon' id='v'}
        <div style="width: 30%;float: left;margin-left: 2.5%;position: relative;"><a href="javascript:get_ticket({$v.id});"><img style="width: 100%;display: block;" id="img_{$v.id}" {if condition="in_array($v.id,$user_coupon)"} src="__STATIC__/img_user/dp-guoqiyouhuiquan1.png" {else/} src="__STATIC__/img_user/dp-youhuiquan1.png" {/if}>
            <span class="dollar">&yen;</span><span class="price">{$v.actual_price}</span><span class="use">满{$v.virtual_price}元可用</span>
        </a></div>
        {if condition="in_array($v.id,$user_coupon)"}
        <input type="hidden" class="flag_{$v.id}" value="1" />
        {else/}
        <input type="hidden" class="flag_{$v.id}" value="2" />
        {/if}
        <input type="hidden" id="last_num_{$v.id}" value="{$v.number}" />
        {/volist}
        {/if}
    </div>
    </div>
    {if condition="$result.pic"}
    <div class="banner">
        <div>
            {notempty name="result.pic.left_id"}
                <a href="javascript:jump_goods({$result.pic.left_id});">
            {else/}
                <a href="#">
            {/notempty}
                <img src="/{$result.pic.left_img}" style="height: 305px;" onerror=this.src='/static/mobile/img/empty_img.png' ></a>
        </div>
        <ul>
            <li>{notempty name="result.pic.right_one_id"}<a href="javascript:jump_goods({$result.pic.right_one_id});">{else/}<a href="#">{/notempty}<img src="/{$result.pic.right_img_one}" style="width: 100%;height: 88px;" onerror=this.src='/static/mobile/img/empty_img.png' ></a></li>
            <li>{notempty name="result.pic.right_two_id"}<a href="javascript:jump_goods({$result.pic.right_two_id});">{else/}<a href="#">{/notempty}<img src="/{$result.pic.right_img_two}" style="width: 100%;height: 88px;" onerror=this.src='/static/mobile/img/empty_img.png' ></a></li>
            <li style="margin-top: 2px;">{notempty name="result.pic.mb_ad_img"}<a href="javascript:jump_goods({$result.pic.mb_ad_id});">{else/}<a href="#">{/notempty}<img src="/{$result.pic.mb_ad_img}" style="width: 100%;height: 126px;" onerror=this.src='/static/mobile/img/empty_img.png' ></a></li>
        </ul>
    </div>
    {/if}
    <input type="hidden" value="{:input('shop_id')}" id="shop_id" />
    <div class="like">
        <p>超值单品</p>
    </div>
    <ul class="list_group" id="show_list"></ul>
{include file="public/shop_footer" /}
</div>
{include file="public/src" /}
<script>
    //搜索
    function search_title(){
        var shop_id = $('#shop_id').val(),
            search = $('#search').val();
        window.location.href="{:url('user_category/shop_all_goods')}?shop_id="+shop_id+"&search="+search;
    }
    function get_ticket(id){
        if (!'{$Think.session.member_id}'){jump_login();return false;}
        var num = $('#last_num_'+id).val();
        if (num <=0 ){layer.open({content:'优惠券已领完',skin:'msg',time:2});return false;};
        var flag = $('.flag_'+id).val();
        if (flag == 1){layer.open({content:'不能重复领取',skin:'msg',time:2});return false};
        $.ajax({
            url:"ticket_act",
            data:{'id':id},
            type:'post',
            dataType:'json',
            success:function (t) {
                if (t.code == 200){
                    layer.open({content:t.message,skin:'msg',time:2});
                    $('#img_'+id).prop('src','__STATIC__/img_user/dp-guoqiyouhuiquan1.png');
                    $('.flag_'+id).val(1);
                }else{
                    layer.open({content:t.message,skin:'msg',time:2});
                }
            },
            error: function () {
                layer.open({content:'网络繁忙,请重试',skin:'msg',time:2});
            }
        })
    }

    //未登录跳转到登录
    function jump_login(){
        layer.open({
            content: '您还未登录,请登录'
            ,btn: ['去登录', '取消']
            ,yes: function(index){
                window.location.href="{:url('mobile/user_port/login')}";
                layer.close(index);
            }
        });
    }
    $(function () {
        //layer流加载
        layui.use('flow', function() {
            var $ = layui.jquery;
            var flow = layui.flow;
            flow.load({
                elem: '#show_list' //流加载容器
                ,isAuto:true
                ,isLazyimg:true
                ,done: function(page, next){ //执行下一页的回调
                    var lis = [];
                    var shop_id = "{:input('shop_id')}";
                    var search = "{:input('search')}";
                    $.ajax({
                        url:"shop_index",
                        dataType:'json',
                        type:'post',
                        data:{'page':page,'shop_id':shop_id,'search':search},
                        success:function(t){
                            layui.each(t.data, function(index, item){
                                lis.push('<li><a href="javascript:jump_goods('+item.id+');"><div class="pic"><img src="/'+item.thumb_img+'" style="height: 150px;" onerror=this.src="/static/mobile/img/empty_img.png">' +
                                    '</div>' +
                                    '<h4 class="title">'+item.title+'</h4>' +
                                    '<div class="price">&yen;'+item.price+'<span class="sale_num">销量 '+item.sale_number+'</span></div></a></li>');
                            });
                            next(lis.join(''), page < t.pages);
                        },
                        error: function () {
                            layer.open({content:'网络繁忙,请重试',skin:'msg',time:2});
                        }
                    })
                }
            });
        });

    });

    function search13() {
        var lKeyCode = (navigator.appname=="Netscape")?event.which:window.event.keyCode; //event.keyCode按的建的代码，13表示回车
        if (lKeyCode ==13){
            var shop_id = $('#shop_id').val(),
                    search = $('#search').val();
            document.activeElement.blur();
            window.location.href="{:url('user_category/shop_all_goods')}?shop_id="+shop_id+"&search="+search;
        }
    }


    //跳转到商品详情页
    function jump_goods(id){
        sessionStorage.setItem('goods_url_back',window.location.href);
        window.location.href = "{:url('mobile/user_category/goods_details')}?goods_id="+id;
    }

    function shop_goods_cate(id) {
        sessionStorage.setItem('shop_cate_back',window.location.href);
        window.location.href="{:url('mobile/user_category/shop_goods_cate')}?shop_id="+id;
    }


</script>
</body>
</html>